package edu.spec.dengyan.week09.class02.work02;

import java.util.ArrayList;
import java.util.List;

/**
 * Author       : Dengyan
 * Date         :
 * Description  :
 */
public class Student {
    private String name;
    private int age;
    private int score;
    private String classNum;

    public Student() {
    }

    public Student(String name, int age, int score, String classNum) {
        this.name = name;
        this.age = age;
        this.score = score;
        this.classNum = classNum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public String getClassNum() {
        return classNum;
    }

    public void setClassNum(String classNum) {
        this.classNum = classNum;
    }

    //其中，classNum 表示学生的班号，例如“class05”。 有如下List List list = new ArrayList();
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(new Student("Tom",18,100,"class05"));
        list.add(new Student("Jerry",22,70,"class04"));
        list.add(new Student("Owen",25,90,"class05"));
        list.add(new Student("Jim",30,80,"class05"));
        list.add(new Student("Steve",28,66,"class06"));
        list.add(new Student("Kevin",24,100,"class04"));
        //1） 计算所有学生的平均年龄
        float f = 0,ave=0;
        for(int i=0;i<list.size();i++){
            Student s=(Student)list.get(i);
            f+=s.getAge();
        }
        ave=f/list.size();
        System.out.println("所有学生的平均年龄"+ave);
        //2） 计算各个班级的平均分
        //class04
        int j=0;
        float f1=0;
        float average1=0;
        for(int i=0;i<list.size();i++){
            Student s=(Student)list.get(i);
            if(s.getClassNum()=="class04"){
                f1+=s.getScore();
                j+=1;
            }
        }
        average1=f1/j;
        System.out.println("class04班级的平均分为："+average1);
        //class05
        int a=0;
        float f2=0;
        float average2=0;
        for(int i=0;i<list.size();i++){
            Student s=(Student)list.get(i);
            if(s.getClassNum()=="class05"){
                f2+=s.getScore();
                a+=1;
            }
        }
        average2=f2/a;
        System.out.println("class05班级的平均分为："+average2);
        //class06
        int b=0;
        float f3=0;
        float average3=0;
        for(int i=0;i<list.size();i++){
            Student s=(Student)list.get(i);
            if(s.getClassNum()=="class06"){
                f3+=s.getScore();
                b+=1;
            }
        }
        average3=f3/b;
        System.out.println("class06班级的平均分为："+average3);
        /*System.out.println("class04班级的平均分为："+(float)(s2.getScore()+s6.getScore())/2);
        System.out.println("class05班级的平均分为："+(float)(s1.getScore()+s3.getScore()+s4.getScore())/3);
        System.out.println("class06班级的平均分为："+s5.getScore());*/
    }
    //list.add(new Student(“Tom”, 18, 100, “class05”));@4554617c
    // 参数第一个表示姓名，第二个是年龄，第三个是分数，第4个是班级
    //list.add(new Student(“Jerry”, 22, 70, “class04”));
    //list.add(new Student(“Owen”, 25, 90, “class05”));
    //list.add(new Student(“Jim”, 30,80 , “class05”));
    //list.add(new Student(“Steve”, 28, 66, “class06”));
    //list.add(new Student(“Kevin”, 24, 100, “class04”));
    //在这个list 的基础上，完成下列要求：



}
